﻿#region ディレクティブを使用する

using System;
using SmartPDA.WMDevice;
using SmartPDA.GetFileInfo;

#endregion

namespace SmartPDA.Windows.Forms
{
	/// <summary>
	/// LoadString の概要の説明です。
	/// </summary>
	internal class LoadString
	{
		#region フィールド

		public string Cancel = "Cancel";
		public string Font = "Font";
		public string Select = "Select";
		public string Size = "Size";
		public string Regular = "Regular";
		public string Bold = "Bold";
		public string Italic = "Italic";
		public string BoldItalic = "Bold Italic";
		public string Underline = "Underline";
		public string Strikethrough = "Strikethrough";
		public string FontPreview = "AaBbYyZz";
		public string FontReadError = "Font Read Error";
		public string FontSizeError = "Size must be a number.";

		//public string Cancel = "_";
		//public string Font = "_";
		//public string Select = "_";
		//public string Size = "_";
		//public string Regular = "_";
		//public string Bold = "_";
		//public string Italic = "_";
		//public string BoldItalic = "_";
		//public string Underline = "_";
		//public string Strikethrough = "_";
		//public string FontPreview = "_";
		//public string FontReadError = "_";
		//public string FontSizeError = "_";

		#endregion

		internal LoadString(PlatformInfo.Platform platform, PlatformInfo.OSEdition edition)
		{
			if (!this.SetString_MUI())
			{
				this.SetString_PPC2003SE(platform, edition);
				this.SetString_PPC2005(platform, edition);
				this.SetString_PPC2006(platform, edition);
				this.SetString_SP2003SE(platform, edition);
				this.SetString_SP2005(platform, edition);
				this.SetString_SP2006(platform, edition);
			}
		}

		#region 文字列リソースの取得

		#region SetString_SatteliteAssembly

		/*
		private bool SetString_SatteliteAssembly()
		{

			#region Protected / Internal Class

			/// <summary>
			/// i18n 用 CulureInfo インスタンスを設定、取得します。
			/// </summary>
			System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CurrentCulture;

			/// <summary>
			/// 文字列リソース、アイコン読み込み用 ResourceManager を設定、取得します。
			/// </summary>
			System.Resources.ResourceManager resMan = new System.Resources.ResourceManager("FontDialog.FontDialog", this.GetType().Assembly);

			#endregion

			#region 文字列取得

			try
			{
				// 文字列取得
				this.Cancel = resMan.GetString("Cancel", culture);
				this.Font = resMan.GetString("Font", culture);
				this.Select = resMan.GetString("Select", culture);
				this.Size = resMan.GetString("Size", culture);
				this.Regular = resMan.GetString("Regular", culture);
				this.Bold = resMan.GetString("Bold", culture);
				this.Italic = resMan.GetString("Italic", culture);
				this.BoldItalic = resMan.GetString("BoldItalic", culture);
				this.Underline = resMan.GetString("Underline", culture);
				this.Strikethrough = resMan.GetString("Strikethrough", culture);
				this.FontPreview = resMan.GetString("FontPreview", culture);
				this.FontReadError = resMan.GetString("FontReadError", culture);
				this.FontSizeError = resMan.GetString("FontSizeError", culture);

				// リソースの開放
				resMan.ReleaseAllResources();

				return true;
			}
			catch
			{
				return false;
			}

			#endregion

		}
		*/

		#endregion

		private bool SetString_MUI()
		{
			string ThisName = System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
			string MUIName = ThisName + "." + System.Globalization.CultureInfo.CurrentCulture.LCID.ToString("x4") + ".mui";

			// プロパティの設定
			string[] tmpStrings = ReadDLLResources.LoadString(MUIName, new int[]{
				1000,	// Cancel
				1001,	// Font
				1002,	// Select
				1003,	// Size
				1004,	// Regular
				1005,	// Bold
				1006,	// Italic
				1007,	// Bold Italic
				1008,	// Underline
				1009,	// Stlikeout
				1010,	// FontPreview
				1011,	// FontReadError
				1012	// FontSizeError
			});

			 if (tmpStrings.Length > 12)
			 {
				 this.Cancel = tmpStrings[0];
				 this.Font = tmpStrings[1];
				 this.Select = tmpStrings[2];
				 this.Size = tmpStrings[3];
				 this.Regular = tmpStrings[4];
				 this.Bold = tmpStrings[5];
				 this.Italic = tmpStrings[6];
				 this.BoldItalic = tmpStrings[7];
				 this.Underline = tmpStrings[8];
				 this.Strikethrough = tmpStrings[9];
				 this.FontPreview = tmpStrings[10];
				 this.FontReadError = tmpStrings[11];
				 this.FontSizeError = tmpStrings[12];

				 return true;
			 }
			 else
			 {
				 return false;
			 }

		}

		private void SetString_PPC2003SE(PlatformInfo.Platform platform, PlatformInfo.OSEdition edition)
		{

			// PPC & 2003SE でない場合は戻る
			if (platform == PlatformInfo.Platform.PocketPC && edition == PlatformInfo.OSEdition.PPC2003SE)
			{

				string tmpString;
				string[] tmpStrings;

				// プロパティの設定
				tmpString = ReadDLLResources.LoadString("Browsres.dll", 6153);

				if (tmpString.Length > 0)
				{
					this.Cancel = tmpString;
				}

				tmpStrings = ReadDLLResources.LoadString("Commdlg.dll", new int[]{
					6524,	// Regular
					6525,	// Bold
					6526,	// Italic
					6527,	// BoldItalic
					6560,	// FontPreview
					6522,	// FontReadError
					6530	// FotnSizeError
				});

				if (tmpStrings.Length > 6)
				{
					this.Regular = tmpStrings[0];
					this.Bold = tmpStrings[1];
					this.Italic = tmpStrings[2];
					this.BoldItalic = tmpStrings[3];
					this.FontPreview = tmpStrings[4];
					this.FontReadError = tmpStrings[5];
					this.FontSizeError = tmpStrings[6];
				}

				tmpStrings = ReadDLLResources.LoadString("Officeres.dll", new int[]{
					12820,	// Select
					12913,	// Size
					12824,	// Underline
					15005	// Font
				});

				if (tmpStrings.Length > 3)
				{
					this.Select = tmpStrings[0];
					this.Size = tmpStrings[1];
					this.Underline = tmpStrings[2];
					this.Font = tmpStrings[3];
				}
			}

		}

		private void SetString_PPC2005(PlatformInfo.Platform platform, PlatformInfo.OSEdition edition)
		{

			// PPC & 2005 でない場合は戻る
			if (platform == PlatformInfo.Platform.PocketPC && edition == PlatformInfo.OSEdition.WM2005)
			{
				// プロパティの設定
				string tmpString;
				string[] tmpStrings;

				tmpString = ReadDLLResources.LoadString("Browsres.dll", 5635);

				if (tmpString.Length > 0)
				{
					this.Cancel = tmpString;
				}

				tmpStrings = ReadDLLResources.LoadString("Commdlg.dll", new int[]{
					6524,	// Regular
					6525,	// Bold
					6526,	// Italic
					6527,	// BoldItalic
					6560,	// FontPreview
					6522,	// FontReadError
					6530	// FotnSizeError
				});

				if (tmpStrings.Length > 6)
				{
					this.Regular = tmpStrings[0];
					this.Bold = tmpStrings[1];
					this.Italic = tmpStrings[2];
					this.BoldItalic = tmpStrings[3];
					this.FontPreview = tmpStrings[4];
					this.FontReadError = tmpStrings[5];
					this.FontSizeError = tmpStrings[6];
				}

				tmpStrings = ReadDLLResources.LoadString("Officeres.dll", new int[]{
					12820,	// Select
					12824,	// Underline
					12913,	// Size
					15005	// Font
				});

				if (tmpStrings.Length > 3)
				{
					this.Select = tmpStrings[0];
					this.Underline = tmpStrings[1];
					this.Size = tmpStrings[2];
					this.Font = tmpStrings[3];
				}
			}

		}

		private void SetString_PPC2006(PlatformInfo.Platform platform, PlatformInfo.OSEdition edition)
		{

			// PPC & 2005 でない場合は戻る
			if (platform == PlatformInfo.Platform.PocketPC && edition == PlatformInfo.OSEdition.WM2006)
			{
						
				// プロパティの設定
				string tmpString;
				string[] tmpStrings;

				tmpString = ReadDLLResources.LoadString("Browsres.dll", 5635);

				if (tmpString.Length > 0)
				{
					this.Cancel = tmpString;
				}


				tmpString = ReadDLLResources.LoadString("shellres.dll", 8671);

				if (tmpString.Length > 0)
				{
					this.Select = tmpString;
				}

				tmpStrings = ReadDLLResources.LoadString("Commdlg.dll", new int[]{
					6524,	// Regular
					6525,	// Bold
					6526,	// Italic
					6527,	// BoldItalic
					6560,	// FontPreview
					6522,	// FontReadError
					6530	// FotnSizeError
				});

				if (tmpStrings.Length > 6)
				{
					this.Regular = tmpStrings[0];
					this.Bold = tmpStrings[1];
					this.Italic = tmpStrings[2];
					this.BoldItalic = tmpStrings[3];
					this.FontPreview = tmpStrings[4];
					this.FontReadError = tmpStrings[5];
					this.FontSizeError = tmpStrings[6];
				}

				tmpStrings = ReadDLLResources.LoadString("Officeres.dll", new int[]{
					12824,	// Underline
					12913,	// Size
					15005	// Font
				});

				if (tmpStrings.Length > 2)
				{
					this.Underline = tmpStrings[0];
					this.Size = tmpStrings[1];
					this.Font = tmpStrings[2];
				}

			}

		}

		private void SetString_SP2003SE(PlatformInfo.Platform platform, PlatformInfo.OSEdition edition)
		{

			// SP & 2003SE でない場合は戻る
			if (platform == PlatformInfo.Platform.Smartphone && edition == PlatformInfo.OSEdition.PPC2003SE)
			{

				// プロパティの設定
				string[] tmpStrings;
				string tmpString;

				tmpStrings = ReadDLLResources.LoadString("Browsres.dll", new int[]{
					4100,	// Cancel
					4117	// Select
				});

				if (tmpStrings.Length > 1)
				{
					this.Cancel = tmpStrings[0];
					this.Select = tmpStrings[1];
				}

				tmpStrings = ReadDLLResources.LoadString("Commdlg.dll", new int[]{
					6520,	// Font == ( Fonts )
					6524,	// Regular
					6525,	// Bold
					6526,	// Italic
					6527,	// BoldItalic
					6560,	// FontPreview
					6522,	// FontReadError
					6530	// FotnSizeError
				});

				if (tmpStrings.Length > 7)
				{
					this.Font = tmpStrings[0];
					this.Regular = tmpStrings[1];
					this.Bold = tmpStrings[2];
					this.Italic = tmpStrings[3];
					this.BoldItalic = tmpStrings[4];
					this.FontPreview = tmpStrings[5];
					this.FontReadError = tmpStrings[6];
					this.FontSizeError = tmpStrings[7];
				}

				tmpString = ReadDLLResources.LoadString("Shellres.dll", 8453);

				if (tmpString.Length > 0)
				{
					this.Size = tmpString;
				}
			}

		}

		private void SetString_SP2005(PlatformInfo.Platform platform, PlatformInfo.OSEdition edition)
		{

			// SP & 2003SE でない場合は戻る
			if (platform == PlatformInfo.Platform.Smartphone && edition == PlatformInfo.OSEdition.WM2005)
			{
				string tmpString;
				string[] tmpStrings;

				// プロパティの設定

				tmpStrings = ReadDLLResources.LoadString("Browsres.dll", new int[]{
					4100,	// Cancel
					4117	// Select
				});

				if (tmpStrings.Length > 1)
				{
					this.Cancel = tmpStrings[0];
					this.Select = tmpStrings[1];
				}


				tmpString = ReadDLLResources.LoadString("Shellres.dll", 8453);

				if (tmpString.Length > 0)
				{
					this.Size = tmpString;
				}

			}

		}

		private void SetString_SP2006(PlatformInfo.Platform platform, PlatformInfo.OSEdition edition)
		{

			// SP & 2003SE でない場合は戻る
			if (platform == PlatformInfo.Platform.Smartphone && edition == PlatformInfo.OSEdition.WM2006)
			{
				string tmpString;

				// プロパティの設定

				tmpString = ReadDLLResources.LoadString("commctrl.dll", 502);

				if (tmpString.Length > 0)
				{
					this.Cancel = tmpString;
				}

				tmpString = ReadDLLResources.LoadString("browsres.dll", 4117);

				if (tmpString.Length > 0)
				{
					this.Select = tmpString;
				}

				tmpString = ReadDLLResources.LoadString("Shellres.dll", 8453);

				if (tmpString.Length > 0)
				{
					this.Size = tmpString;
				}

			}

		}

		#endregion

	}
}
